package com.itheima.dianming.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.dianming.pojo.domain.ExamLog;
import com.itheima.dianming.pojo.vo.ExamLogVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ExamLogMapper extends BaseMapper<ExamLog> {

    @Select("SELECT \n" +
            "t2.id," +
            "t1.username,\n" +
            "t2.`content`,\n" +
            "t3.`url`,\n" +
            "IF(t2.`exam_id` IS NULL,'未完成','完成') isdown\n" +
            "FROM tb_stu t1\n" +
            "LEFT JOIN `tb_exam_log` t2 ON t1.id = t2.`stu_id` AND t2.`exam_id` = #{examId}\n" +
            "LEFT JOIN `tb_exam` t3 ON t2.`exam_id` = t3.`id`\n" +
            "ORDER BY isdown ASC ,t1.username  asc")
    List<ExamLogVo> listExam(String examId);
}
